import { Rect } from "leafer-ui";
import { ComputedRef, Ref } from "vue";
import { App, Group, Leafer } from "leafer-ui";

export type TextBox = {
  x: number;
  y: number;
  width: number;
  height: number;
  boxId: string | number;
  id: string;
  data: {
    text: string;
    index: number;
    pageIndex: number;
    rowIndex:number;
    paragraphIndex:number;
  };
} & Rect;

export type IToolReturn = {
  eventsMap: Record<string, (event: any) => void>;
  active: () => void;
  deactive: () => void;
};
export interface IUseHistoryUtil<T> {
  data: Ref<T | undefined>;
  init: (initialData: T) => void;
  commit: (data: T) => void;
  redo: () => void;
  undo: () => void;
  canRedo: ComputedRef<boolean>;
  canUndo: ComputedRef<boolean>;
  index: Ref<number>;
  getCloneData: () => T;
  getHistoryList: () => T[];
}
export type ITool = (options: {
  app: App;
  commit: (data: { selectedTextBoxes: TextBox[] }) => void;
  target: (index?: number) => Group;
  imgList: string[];
}) => IToolReturn;

export type MarkSentenceItem = {
  textList: TextBox[];
  mark: string;
};
export type MarkParagraphItem = {
  textList: TextBox[];
  mark: string;
};
export type MarkWordItem = {
  text: TextBox;
  mark: string;
};
